Skip to content

Conversation

gbarkhatov
Copy link
Collaborator

@gbarkhatov gbarkhatov commented Oct 10, 2025

initial implementation of co-staking via API calculating APRs for front-end

concern: usage of window.dispatchEvent to overcome the provider issue. @necipsagiro I extracted this to a new ticket as an improvement, so we can rollout the co-staking faster: #369

Closes #353

@gbarkhatov gbarkhatov marked this pull request as ready for review October 13, 2025 08:55
@Copilot Copilot AI review requested due to automatic review settings October 13, 2025 08:55
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a co-staking API that provides personalized APR calculations from the backend, replacing complex frontend calculations with simpler API-based data retrieval.

Key changes:

  • Replaces frontend APR calculations with backend API calls that provide personalized APR data
  • Refactors co-staking state management to use real-time BTC/BABY staking totals from confirmed and pending operations
  • Implements localStorage-based tracking for pending BABY operations with cross-tab synchronization

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
coStakingCalculations.ts Removes complex frontend APR calculation functions, keeping only basic utility functions
coStaking.ts Updates type definitions to support personalized APR response structure from backend
CoStakingState.tsx Major refactor to calculate totals from delegation data and localStorage, adds cross-tab sync
rewards/index.tsx Simplifies co-staking reward calculation using API-provided APR ratios
useTransactionService.ts Adds query invalidation to trigger APR updates after BTC staking transactions
useCoStakingService.ts Complete rewrite to use backend APR API instead of frontend calculations
CoStakingBoostModal.tsx Updates to use new state management approach
getAPR.ts Replaces generic APR fetch with personalized APR API call
usePendingOperationsService.tsx Adds window event dispatch for cross-tab localStorage synchronization
useDelegationService.ts Adds query invalidation to trigger APR updates after BABY delegation transactions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@jrwbabylonlab jrwbabylonlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gbarkhatov gbarkhatov merged commit d7976d8 into main Oct 13, 2025
4 checks passed
@gbarkhatov gbarkhatov deleted the feat/co-staking-apr-calcs-api branch October 13, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Co-staking] - APR API data

2 participants